<#include "/WEB-INF/template/common/macro/base.ftl"/>
<#include "/WEB-INF/template/common/macro/libs.ftl"/>
<#include "/WEB-INF/template/common/layout/l_admin.ftl"/>
<#include "/WEB-INF/template/common/macro/fileupload.ftl"/>
<@adminLayout>
    <@breadcrumb view=breadcrumbView/>
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet box light-grey">
            <div class="portlet-title">
                <div class="caption"><i class="fa fa-globe"></i>${breadcrumbView.getCurmenu().name!}</div>
                <div class="actions">
                    <button id="list_add" class="btn blue" data-toggle="modal" href="#responsive">
                        <i class="fa fa-plus-circle"></i>
                        添加
                    </button>
                </div>
            </div>
            <div id="dt_grid" class="dt-grid-container portlet-body" >
            </div>
            <div id ="dt_table_toolbar" class="dt-grid-toolbar-container">
            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>
    <!--model begin-->
    <@Modal_CURD "ajax_add" "modal-wide" "users_add"/>
    <@Modal_CURD "ajax_update" "modal-wide" "users_update"/>
    <@Modal_SystemOpera/>
    <!--model end-->
</div>
    <@script>
        <@libs_dtgrid_js/>
        <@libs_dtgrid_css/>
        <@libs_jquery_validate_js/>
        <@libs_fileupload/>
    <script type="text/javascript">
        var datas = new Array();
        var dtgrid="";
        jQuery(document).ready(function () {
            var columnModel = [
                {id:'name', title:'登录名', type:'string', columnClass:'text-center'},
                {id:'tel', title:'电话', type:'string', columnClass:'text-center'},
                {id:'email', title:'Email', type:'string', columnClass:'text-center'},
                {id:'createtime', title:'发布日期', type:'string', columnClass:'text-center'},
                {title:'操作',columnClass:'text-center',
                    resolution:function(value, record){
                        var content = [];
                        content.push("<a href=\"javascript:;\" onclick=\"update(this,'"+record.uuid+"')\" class=\"btn btn-primary btn-xs\">");
                        content.push("<i class=\"fa fa-pencil update\"></i></a>");
                        content.push("<a href=\"javascript:;\" onclick=\"deletebyid(this,'"+record.uuid+"')\" class=\"btn btn-danger btn-xs\">");
                        content.push("<i class=\"fa fa-minus-circle\"></i></a>");
                        return content.join(" ");
                    }}
            ];

            var dtgridOpt = {
                lang: 'zh-cn',
                ajaxLoad : true,
                loadURL : '${CONTEXT_PATH}/m/user/load',
                exportFileName : '系统用户列表',
                columns : columnModel,
                gridContainer : 'dt_grid',
                toolbarContainer : 'dt_table_toolbar',
                tools : 'print',
                pageSize : 10,
                pageSizeLimit : [10, 20, 50]
            };
            dtgrid = $.fn.DtGrid.init(dtgridOpt);
            $(function(){
                dtgrid.load();
            });

            var addobj = $.extend(CONST_ACTION.ADD, {
                modaldom: $("#ajax_add"),
                actiondom: $("#list_add"),
                actionurl: "${CONTEXT_PATH}/m/user/add",
                okevent: function (config) {
                },
                afterok:function(config){
                }
            });
            setFormAjaxAction(addobj);
        });

        function update(obj, id) {
            var updateobj = $.extend(CONST_ACTION.UPDATE, {
                modaldom: $("#ajax_update"),
                actiondom: $(obj),
                actionurl: "${CONTEXT_PATH}/m/user/edit/" + id,
                okevent: function (config) {
                },
                afterok:function(config){
                }
            });
            updateEvent(updateobj);
        }

        function deletebyid(obj, id) {
            var cfg = $.extend(CONST_ACTION.DELETE, {
                actiondom: $(obj),
                actionurl: "${CONTEXT_PATH}/m/user/delete/" + id,
                afterok:function(config){
                    dtgrid.load();
                }
            })
            SystemConfirm(cfg)
        }
    </script>
    </@script>
</@adminLayout>